home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
telecomm
/
sticpsrc.lzh
/
SOURCE.ARC
/
IFACE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-07-18
|
2KB
|
75 lines
#include "global.h"
#include "iface.h"
static char if_unknown[] = "Interface \"%s\" unknown\n";
/* find an interface, return pointer or NULLIF on error. print diagnostic. */
struct interface *
ifunit(name)
char *name;
{
register struct interface *ifp;
for(ifp=ifaces;ifp != NULLIF;ifp = ifp->next){
if(strcmp(name,ifp->name) == 0)
return ifp;;
}
printf(if_unknown,name);
return NULLIF;
}
struct interface *
if_lookup(name)
char *name;
{
register struct interface *iface;
for(iface = ifaces; iface != NULLIF; iface = iface->next)
if(strcmp(iface->name,name) == 0)
break;
return iface;
}
/* Divert output packets from one interface to another. Useful for ARP
* and digipeat frames coming in from receive-only interfaces
*/
doforward(argc,argv)
int argc;
char *argv[];
{
struct interface *iface,*iface1;
if(argc < 2){
for(iface = ifaces; iface != NULLIF; iface = iface->next){
if(iface->forw != NULLIF){
printf("%s -> %s\n",iface->name,iface->forw->name);
}
}
return 0;
}
if((iface = if_lookup(argv[1])) == NULLIF){
printf(if_unknown,argv[1]);
return 1;
}
if(argc < 3){
if(iface->forw == NULLIF)
printf("%s not forwarded\n",iface->name);
else
printf("%s -> %s\n",iface->name,iface->forw->name);
return 0;
}
if((iface1 = if_lookup(argv[2])) == NULLIF){
printf(if_unknown,argv[2]);
return 1;
}
if(iface1 == iface){
/* Forward to self means "turn forwarding off" */
iface->forw = NULLIF;
} else {
if(iface1->output != iface->output)
printf("Warning: Interfaces of different type\n");
iface->forw = iface1;
}
return 0;
}